package com.example.academicsystem.server.dao;

import com.example.academicsystem.pojo.dto.*;
import com.example.academicsystem.pojo.vo.AdminLoginVo;
import com.example.academicsystem.pojo.vo.StudentLoginVo;
import com.example.academicsystem.pojo.vo.TeacherLoginVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

@Mapper
@Component
public interface UserMapper {
    @Select("select name,student_id from student where student_id=#{studentId} and password=#{password} ")
    StudentLoginVo studentLogin(StudentLoginDto studentLoginDto);

    @Select("select name,teacher_id from teacher where teacher_id=#{teacherId}and password=#{password}")
    TeacherLoginVo teacherLogin(TeacherLoginDto teacherLoginDto);
    @Select("select name,admin_id from admin where admin_id=#{adminId}and password=#{password}")
    AdminLoginVo adminLogin(AdminLoginDto adminLoginDto);

    @Update("update admin set password=#{newPwd} where admin_id = #{id} and password=#{oldPwd}")
    void adminPwdUpdate(PwdUpdateDto pwdUpdateDto);
    @Update("update student set password=#{newPwd} where student_id = #{id} and password=#{oldPwd}")
    void studentPwdUpdate(PwdUpdateDto pwdUpdateDto);
    @Update("update teacher set password=#{newPwd} where teacher_id = #{id} and password=#{oldPwd}")
    void teacherPwdUpdate(PwdUpdateDto pwdUpdateDto);

/*    @Insert("insert into student(student_id,password) values(#{username},#{password})")
    void studentRegister(RegisterDto registerDto);
    @Insert("insert into teacher(teacher_id,password) values(#{username},#{password})")
    void teacherRegister(RegisterDto registerDto);
    @Insert("insert into admin(admin_id,password) values(#{username},#{password})")
    void adminRegister(RegisterDto registerDto);*/


}
